﻿using System;
using System.IO;
using System.Web;
using System.Web.UI;

namespace YanProV1.View
{
    public partial class ISOPageView : Page
    {
        

        //private string strfilename
        //{
        //    get
        //    {
        //        //int id = Convert.ToInt32(Request.QueryString["id"].ToString());
        //        //ly.Model.WJ_ZiDianM model = bllwj.GetModel(id);
        //        if (model != null)
        //        {
        //            //lbName.Text = model.WJName;

        //            return model.WJAddress.ToString();
        //        }
        //        else
        //        {
        //            return " ";
        //        }
        //    }
            
        //}

        protected void Page_Load(object sender, EventArgs e)
        {
           // hidefilename.Value = strfilename.Replace("doc", "swf");
        }

        protected void lbtnXiaZai_Click(object sender, EventArgs e)
        {
            FileDownLoad();
        }

        /// <summary>
        /// 文件下载
        /// </summary>
        /// <param name="savename">服务器上保存的文件名</param>
        /// <param name="path">服务器路径</param>
        /// <param name="filename">下载文件名</param>
        public void FileDownLoad()
        {
            //int id = Convert.ToInt32(Request.QueryString["id"].ToString());
            //ly.Model.WJ_ZiDianM model = bllwj.GetModel(id);
            //if (model != null)
            //{
            //    string filePath = Server.MapPath(@"../../View/UpLoadFile/ISO/FLASH/") + model.WJAddress.ToString();
            //    try
            //    {
            //        if (File.Exists(filePath))
            //        {
            //            FileInfo fileInfo = new FileInfo(filePath);
            //            Response.Clear();
            //            Response.ClearContent();
            //            Response.ClearHeaders();
            //            //Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);文件名为中文是下载出错
            //            Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(model.WJAddress, System.Text.Encoding.UTF8));
            //            Response.AddHeader("Content-Length", fileInfo.Length.ToString());
            //            Response.AddHeader("Content-Transfer-Encoding", "binary");
            //            Response.ContentType = "application/octet-stream";
            //            Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
            //            Response.WriteFile(fileInfo.FullName);
            //            Response.Flush();
            //            Response.End();
            //        }
            //        else
            //        {
            //            Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", "<script>alert('文件不存在或已经被删除!');</script>");
            //        }
            //    }
            //    catch
            //    {
            //        Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", "<script>alert('下载文件错误，请稍后操作!');</script>");
            //    }
            //}
        }
    }
}